<html>
<head>
 <link rel="stylesheet" href="/static/admin/style.css" type="text/css" media="screen" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/static/js/handlers.js"></script>
	<script type="text/javascript">
		function window_onload(){
		var my=this.parent.document;
		var h = my.getElementById("albumkey").value;
		this.document.getElementById("albumkey").value=h;
		};



		var swfu;

		function init_swfu() {
			swfu = new SWFUpload({
				// Backend Settings
				upload_url: "{{upload_url}}",
				// File Upload Settings
				file_size_limit : "1 MB",
				file_types : "*.jpg",
				file_types_description : "JPG Images",
				file_upload_limit : "0",    // Zero means unlimited
				post_params : {
						    "description" : "",
									"name":"",
									"url":"",
									"albumkey":"1"
						},
				// Event Handler Settings - these functions as defined in Handlers.js
				//  The handlers are not part of SWFUpload but are part of my website and control how
				//  my website reacts to the SWFUpload events.
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_progress_handler : uploadProgress,
				file_dialog_start_handler: setPost,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,

				// Button settings
				button_image_url : "/static/images/XPButtonNoText_160x22.png",
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 160,
				button_height: 22,
				button_text : '<span class="button">Select Images <span class="buttonSmall">(1 MB Max)</span></span>',
				button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
				button_text_top_padding: 1,
				button_text_left_padding: 5,

				// Flash Settings
				flash_url : "/static/swfupload/swfupload.swf",	// Relative to this file

				custom_settings : {
					upload_target : "divFileProgressContainer"
				},

				// Debug Settings
				debug: false
			});
		}
		$(document).ready(function(){
			init_swfu();
			swfu.settings.post_params.album=$('#albumkey').val();
			swfu.settings.post_params.name=$('#name').val();
			swfu.settings.post_params.description=$('#description').val();
			swfu.settings.post_params.url=$('#url').val();
			$('#albumkey').change(function(){
			   album = $(this).val();
			   swfu.addPostParam("albumkey", album);
			});
		});
		function setPost()  //动态传递参数
        {
	  name = $('#name').val();
	  description=$('#description').val();
	  url=$('#url').val();
          swfu.addPostParam("name", name);
	  swfu.addPostParam("description", description);
	  swfu.addPostParam("url", url);//动态修改SWFUpload初始化设置中的post_params属性，其中所有的值都将被覆盖。
          album = $('#albumkey').val();
          swfu.addPostParam("albumkey", album);//动态修改SWFUpload初始化设置中的post_params属性，其中所有的值都将被覆盖。
        };

	function setText(objId,x,newText) {
							with (this.parent.document) if (getElementById && ((obj=getElementById(objId))!=null))
							with (obj) innerHTML += unescape(newText);};
	</script>
</head>
<body onload="window_onload();">
<form id="upload_form" action="{{upload_url}}" enctype="multipart/form-data" method="post">
  <fieldset>
<p><label>标题</label><input type="text" name="name"  id="name" class="input" /> | Url <input type="text" name="url" id="url" class="input"  /></p>
<p><label>说明</label><textarea name="description" id="description" cols="100" rows="10" wrap="virtual"></textarea></p>
<input name="albumkey" id="albumkey" type="hidden" value="{{albumkey}}" />
<div id="swfu_container" style="margin: 0px 10px;">
		    <div>
				<span id="spanButtonPlaceholder"></span>
		    </div>
		    <div id="divFileProgressContainer" style="height: 75px;"></div>
		    <div id="thumbnails"></div>
	    </div>
<!--
<p><label>上传文件(小于1,024kb)</label></p>
<p><input type="file" name="Filedata" id="Filedata" /></p>
<p><input type="submit" value="上传" class="button"/></p>
-->
  </fieldset>
</form>


</body>
</html>
